# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=jupyter-server
pkgver=2.5.0
pkgrel=3
pkgdesc='Provides the backend for Jupyter web applications like Jupyter notebook, JupyterLab, and Voila'
arch=(any)
url='https://jupyter.org/'
license=(custom)
depends=(python-jupyter_client jupyter-nbformat jupyter-nbconvert python-terminado python-prometheus_client python-traitlets python-tornado
         python-jinja python-send2trash python-anyio python-jupyter_packaging python-websocket-client python-requests-unixsocket
         python-argon2_cffi python-jupyter-events)
makedepends=(python-build python-installer python-hatch-jupyter-builder)
checkdepends=(python-pytest-tornasync python-pytest-console-scripts python-pytest-timeout python-pytest-jupyter)
optdepends=('jupyter-server-mathjax: to use local MathJax')
source=(https://pypi.io/packages/source/j/${pkgname/-/_}/${pkgname/-/_}-$pkgver.tar.gz)
sha256sums=('9fde612791f716fd34d610cd939704a9639643744751ba66e7ee8fdc9cead07e')

prepare() {
  cd ${pkgname/-/_}-$pkgver
  sed -e '/jupyter_server_terminals/d' -i pyproject.toml # Prevent cyclic dependencies
}

build() {
  cd ${pkgname/-/_}-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd ${pkgname/-/_}-$pkgver
# tests fail on the build server, run them locally
# pytest -v
}

package() {
  cd ${pkgname/-/_}-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
